package base;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

/**
 * ClassName:Base
 * Package:base
 * Description:DesiredCapabilities 配置项
 * todo:DesiredCapabilities高阶属性配置
 * Date:2021/12/8 19:21
 * Author:zs
 *
 */
public class Base {
     static AndroidDriver driver;

    @BeforeAll
    static void setUp() throws MalformedURLException {
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("platformName", "Android");
        desiredCapabilities.setCapability("appPackage", "com.xueqiu.android");
        desiredCapabilities.setCapability("appActivity", ".common.MainActivity");
        /**udid 设备唯一id
         mumu模拟器 不写udid可以正常运行的
         todo:真机没试过
         */
        // desiredCapabilities.setCapability("udid","7525023d");
        /*
         * device 值可为任意的； 模拟器不传 不报错
         * todo：真机没试过
         * */
        //  desiredCapabilities.setCapability("device", "dv_zs");
        desiredCapabilities.setCapability("ensureWebviewsHavePages", true);
        desiredCapabilities.setCapability("nativeWebScreenshot", true);
        //  desiredCapabilities.setCapability("chromeOptions", {"w3c":false});

        URL remoteUrl = new URL("http://127.0.0.1:4723/wd/hub");

        driver = new AndroidDriver(remoteUrl, desiredCapabilities);
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

    }



    @AfterAll
    static void tearDown() {
        driver.quit();
    }
}
